package cn.weiron.fun.sample.controller;


import cn.weiron.fun.infrastructure.auth.Authority;
import cn.weiron.fun.infrastructure.dto.PageResult;
import cn.weiron.fun.sample.dto.SamplePointTimeRequestDto;
import cn.weiron.fun.sample.entity.SamplePointTime;
import cn.weiron.fun.sample.service.SamplePointTimeService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * (SamplePointTime)表控制层
 *
 * @author makejava
 * @since 2022-07-16 10:36:20
 */
@RestController
@RequestMapping("/samplePointTime")
public class SamplePointTimeController {

    public SamplePointTimeController(@Qualifier("samplePointTimeServiceImpl") SamplePointTimeService samplePointTimeService) {
        this.samplePointTimeService = samplePointTimeService;
    }

    /**
     * 服务对象
     */
    private final SamplePointTimeService samplePointTimeService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @GetMapping
    public PageResult<SamplePointTime> queryByPage(SamplePointTimeRequestDto dto) {
        return samplePointTimeService.queryByPage(dto);
    }



    /**
     * 新增数据
     *
     * @param samplePointTime 实体
     * @return 新增结果
     */
    @PostMapping("/insert")
    public ResponseEntity<SamplePointTime> add(SamplePointTime samplePointTime) {
        return ResponseEntity.ok(this.samplePointTimeService.insert(samplePointTime));
    }



    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.samplePointTimeService.deleteById(id));
    }

}

